.align 2
.section .data
e:
	.zero	1024
book:
	.zero	64
dis:
	.zero	64
n:
	.word	0
m:
	.word	0
v1:
	.word	0
v2:
	.word	0
w:
	.word	0
.section .text
.global __aeabi_memclr4
__aeabi_memclr4:
.L1:
		MV	t5, a0
		MV	t6, a1
		ADD	t6, a0, t6
		LI	a0, 0
.L2:
		SW	zero, (t5)
		ADDI	t5, t5, 4
		BLT	t5, t6, .L2
		RET
.global Dijkstra
Dijkstra:
.L3:
		ADDI	sp, sp, -704
		SD	fp, 40(sp)
		ADDI	fp, sp, 704
		SD	ra, -672(fp)
		SD	s2, -680(fp)
		SD	s3, -688(fp)
		SD	s4, -696(fp)
		SD	s5, -704(fp)
.L4:
		LI	t0, 1
		SW	t0, -656(fp)
		J	.L5
.L6:
		LD	s5, -704(fp)
		LD	s4, -696(fp)
		LD	s3, -688(fp)
		LD	s2, -680(fp)
		LD	ra, -672(fp)
		LD	fp, -664(fp)
		ADDI	sp, sp, 704
		RET
.L5:
		LW	s2, -656(fp)
		LA	t5, n
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -16(fp)
		SW	s3, -24(fp)
		SW	s4, -32(fp)
		LW	s2, -32(fp)
		BGTZ	s2, .L7
		J	.L8
.L7:
		LW	s3, -656(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -48(fp)
		LW	s4, -656(fp)
		LA	t2, e
		LI	t3, 4
		MUL	t3, s4, t3
		ADD	t2, t3, t2
		ADDI	t2, t2, 64
		SD	t2, -64(fp)
		SW	s2, -32(fp)
		LD	t4, -64(fp)
		LW	s2, (t4)
		LD	t4, -48(fp)
		SW	s2, (t4)
		SW	s3, -40(fp)
		LW	s3, -656(fp)
		LA	t2, book
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -88(fp)
		LD	t4, -88(fp)
		LI	t0, 0
		SW	t0, (t4)
		SW	s4, -56(fp)
		LW	s4, -656(fp)
		SW	s2, -72(fp)
		LI	s2, 1
		SW	s3, -80(fp)
		ADDW	s3, s4, s2
		SW	s3, -656(fp)
		SW	s3, -104(fp)
		SW	s4, -96(fp)
		J	.L5
.L8:
		LA	t2, book
		ADDI	t2, t2, 4
		SD	t2, -112(fp)
		LD	t4, -112(fp)
		LI	t0, 1
		SW	t0, (t4)
		LI	t0, 1
		SW	t0, -656(fp)
		J	.L9
.L9:
		LW	s2, -656(fp)
		LA	t5, n
		LW	s3, (t5)
		LI	s4, 1
		SW	s2, -120(fp)
		SUB	s2, s3, s4
		SW	s3, -128(fp)
		LW	s3, -120(fp)
		SLT	s4, s2, s3
		XORI	s4, s4, 1
		SW	s2, -136(fp)
		SW	s3, -120(fp)
		SW	s4, -144(fp)
		LW	s2, -144(fp)
		BGTZ	s2, .L10
		J	.L11
.L10:
		LI	t0, 65535
		SW	t0, -640(fp)
		LI	t0, 0
		SW	t0, -632(fp)
		LI	t0, 1
		SW	t0, -624(fp)
		SW	s2, -144(fp)
		J	.L12
.L11:
		J	.L6
.L12:
		LW	s2, -624(fp)
		LA	t5, n
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -176(fp)
		SW	s3, -184(fp)
		SW	s4, -192(fp)
		LW	s2, -192(fp)
		BGTZ	s2, .L13
		J	.L14
.L13:
		LW	s3, -640(fp)
		LW	s4, -624(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s4, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -216(fp)
		SW	s2, -192(fp)
		LD	t4, -216(fp)
		LW	s2, (t4)
		SW	s4, -208(fp)
		SLT	s4, s2, s3
		SW	s2, -224(fp)
		SW	s3, -200(fp)
		SW	s4, -232(fp)
		LW	s2, -232(fp)
		BGTZ	s2, .L15
		J	.L16
.L14:
		LW	s3, -632(fp)
		LA	t2, book
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -248(fp)
		LD	t4, -248(fp)
		LI	t0, 1
		SW	t0, (t4)
		LI	t0, 1
		SW	t0, -616(fp)
		SW	s2, -232(fp)
		SW	s3, -240(fp)
		J	.L17
.L18:
		LW	s2, -624(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -272(fp)
		LD	t4, -272(fp)
		LW	s3, (t4)
		SW	s3, -640(fp)
		LW	s4, -624(fp)
		SW	s4, -632(fp)
		SW	s2, -264(fp)
		SW	s3, -280(fp)
		SW	s4, -288(fp)
		J	.L16
.L16:
		LW	s2, -624(fp)
		LI	s3, 1
		ADDW	s4, s2, s3
		SW	s4, -624(fp)
		SW	s2, -296(fp)
		SW	s4, -304(fp)
		J	.L12
.L15:
		LW	s2, -624(fp)
		LA	t2, book
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -320(fp)
		LD	t4, -320(fp)
		LW	s3, (t4)
		LI	s4, 0
		SW	s2, -312(fp)
		SUB	t6, s3, s4
		SEQZ	s2, t6
		SW	s2, -336(fp)
		SW	s3, -328(fp)
		LW	s2, -336(fp)
		BGTZ	s2, .L18
		J	.L16
.L17:
		LW	s3, -616(fp)
		LA	t5, n
		LW	s4, (t5)
		SW	s2, -336(fp)
		SLT	s2, s4, s3
		XORI	s2, s2, 1
		SW	s2, -360(fp)
		SW	s3, -344(fp)
		SW	s4, -352(fp)
		LW	s2, -360(fp)
		BGTZ	s2, .L19
		J	.L20
.L19:
		LW	s3, -632(fp)
		LW	s4, -616(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s4, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -384(fp)
		SW	s2, -360(fp)
		LD	t4, -384(fp)
		LW	s2, (t4)
		SW	s3, -368(fp)
		LI	s3, 65535
		SW	s4, -376(fp)
		SLT	s4, s2, s3
		SW	s2, -392(fp)
		SW	s4, -400(fp)
		LW	s2, -400(fp)
		BGTZ	s2, .L21
		J	.L22
.L20:
		LW	s3, -656(fp)
		LI	s4, 1
		SW	s2, -400(fp)
		ADDW	s2, s3, s4
		SW	s2, -656(fp)
		SW	s2, -416(fp)
		SW	s3, -408(fp)
		J	.L9
.L21:
		LW	s2, -616(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -432(fp)
		LD	t4, -432(fp)
		LW	s3, (t4)
		LW	s4, -632(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s4, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -456(fp)
		SW	s2, -424(fp)
		LD	t4, -456(fp)
		LW	s2, (t4)
		SW	s3, -440(fp)
		LW	s3, -632(fp)
		LW	s5, -616(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s5, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -488(fp)
		SW	s2, -464(fp)
		LD	t4, -488(fp)
		LW	s2, (t4)
		SW	s4, -448(fp)
		LW	s4, -464(fp)
		SW	s3, -472(fp)
		ADDW	s3, s4, s2
		SW	s4, -464(fp)
		LW	s4, -440(fp)
		SW	s2, -496(fp)
		SLT	s2, s3, s4
		SW	s2, -512(fp)
		SW	s3, -504(fp)
		SW	s4, -440(fp)
		SW	s5, -480(fp)
		LW	s2, -512(fp)
		BGTZ	s2, .L23
		J	.L24
.L22:
		LW	s3, -616(fp)
		LI	s4, 1
		SW	s2, -512(fp)
		ADDW	s2, s3, s4
		SW	s2, -616(fp)
		SW	s2, -528(fp)
		SW	s3, -520(fp)
		J	.L17
.L23:
		LW	s2, -616(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -544(fp)
		LW	s3, -632(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -560(fp)
		LD	t4, -560(fp)
		LW	s4, (t4)
		SW	s2, -536(fp)
		LW	s2, -632(fp)
		LW	s5, -616(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s5, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -592(fp)
		SW	s3, -552(fp)
		LD	t4, -592(fp)
		LW	s3, (t4)
		SW	s2, -576(fp)
		ADDW	s2, s4, s3
		LD	t4, -544(fp)
		SW	s2, (t4)
		SW	s2, -608(fp)
		SW	s3, -600(fp)
		SW	s4, -568(fp)
		SW	s5, -584(fp)
		J	.L24
.L24:
		J	.L22
.global main
main:
.L25:
		ADDI	sp, sp, -456
		SD	fp, 40(sp)
		ADDI	fp, sp, 456
		SD	ra, -424(fp)
		SD	s2, -432(fp)
		SD	s3, -440(fp)
		SD	s4, -448(fp)
		SD	s5, -456(fp)
.L26:
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -8(fp)
		LW	s2, -8(fp)
		LA	t5, n
		SW	s2, (t5)
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -16(fp)
		LW	s3, -16(fp)
		LA	t5, m
		SW	s3, (t5)
		LI	t0, 1
		SW	t0, -400(fp)
		SW	s2, -8(fp)
		SW	s3, -16(fp)
		J	.L27
.L28:
		LW	s2, -408(fp)
		SW	s2, -32(fp)
		LW	a0, -32(fp)
		LD	s5, -456(fp)
		LD	s4, -448(fp)
		LD	s3, -440(fp)
		LD	s2, -432(fp)
		LD	ra, -424(fp)
		LD	fp, -416(fp)
		ADDI	sp, sp, 456
		RET
.L27:
		LW	s2, -400(fp)
		LA	t5, n
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -48(fp)
		SW	a0, -32(fp)
		SW	s3, -56(fp)
		SW	s4, -64(fp)
		LW	s2, -64(fp)
		BGTZ	s2, .L29
		J	.L30
.L29:
		LI	t0, 1
		SW	t0, -392(fp)
		SW	s2, -64(fp)
		J	.L31
.L30:
		LI	t0, 1
		SW	t0, -400(fp)
		J	.L32
.L31:
		LW	s2, -392(fp)
		LA	t5, n
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -80(fp)
		SW	s3, -88(fp)
		SW	s4, -96(fp)
		LW	s2, -96(fp)
		BGTZ	s2, .L33
		J	.L34
.L33:
		LW	s3, -400(fp)
		LW	s4, -392(fp)
		SW	s2, -96(fp)
		SUB	t6, s3, s4
		SEQZ	s2, t6
		SW	s2, -120(fp)
		SW	s3, -104(fp)
		SW	s4, -112(fp)
		LW	s2, -120(fp)
		BGTZ	s2, .L35
		J	.L36
.L34:
		LW	s3, -400(fp)
		LI	s4, 1
		SW	s2, -120(fp)
		ADDW	s2, s3, s4
		SW	s2, -400(fp)
		SW	s2, -136(fp)
		SW	s3, -128(fp)
		J	.L27
.L35:
		LW	s2, -400(fp)
		LW	s3, -392(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -160(fp)
		LD	t4, -160(fp)
		LI	t0, 0
		SW	t0, (t4)
		SW	s2, -144(fp)
		SW	s3, -152(fp)
		J	.L37
.L36:
		LW	s2, -400(fp)
		LW	s3, -392(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -184(fp)
		LD	t4, -184(fp)
		LI	t0, 65535
		SW	t0, (t4)
		SW	s2, -168(fp)
		SW	s3, -176(fp)
		J	.L37
.L37:
		LW	s2, -392(fp)
		LI	s3, 1
		ADDW	s4, s2, s3
		SW	s4, -392(fp)
		SW	s2, -192(fp)
		SW	s4, -200(fp)
		J	.L31
.L32:
		LW	s2, -400(fp)
		LA	t5, m
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -208(fp)
		SW	s3, -216(fp)
		SW	s4, -224(fp)
		LW	s2, -224(fp)
		BGTZ	s2, .L38
		J	.L39
.L38:
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -232(fp)
		LW	s3, -232(fp)
		SW	s3, -384(fp)
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -248(fp)
		LW	s4, -248(fp)
		SW	s4, -376(fp)
		LW	s5, -384(fp)
		SW	s2, -224(fp)
		LW	s2, -376(fp)
		LA	t2, e
		LI	t3, 64
		MUL	t3, s5, t3
		ADD	t2, t3, t2
		LI	t3, 4
		MUL	t3, s2, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -280(fp)
		ADDI	sp, sp, -8
		CALL	getint
		ADDI	sp, sp, 8
		SW	a0, -288(fp)
		SW	s3, -232(fp)
		LW	s3, -288(fp)
		LD	t4, -280(fp)
		SW	s3, (t4)
		SW	s4, -248(fp)
		LW	s4, -400(fp)
		SW	s2, -272(fp)
		LI	s2, 1
		SW	s3, -288(fp)
		ADDW	s3, s4, s2
		SW	s3, -400(fp)
		SW	s3, -304(fp)
		SW	s4, -296(fp)
		SW	s5, -264(fp)
		J	.L32
.L39:
		ADDI	sp, sp, -8
		CALL	Dijkstra
		ADDI	sp, sp, 8
		LI	t0, 1
		SW	t0, -400(fp)
		J	.L40
.L40:
		LW	s2, -400(fp)
		LA	t5, n
		LW	s3, (t5)
		SLT	s4, s3, s2
		XORI	s4, s4, 1
		SW	s2, -312(fp)
		SW	s3, -320(fp)
		SW	s4, -328(fp)
		LW	s2, -328(fp)
		BGTZ	s2, .L41
		J	.L42
.L41:
		LW	s3, -400(fp)
		LA	t2, dis
		LI	t3, 4
		MUL	t3, s3, t3
		ADD	t2, t3, t2
		ADD	t2, t2, zero
		SD	t2, -344(fp)
		LD	t4, -344(fp)
		LW	s4, (t4)
		ADDI	sp, sp, -24
		SW	s4, -352(fp)
		LW	a0, -352(fp)
		CALL	putint
		ADDI	sp, sp, 24
		ADDI	sp, sp, -24
		SW	a0, -352(fp)
		LI	a0, 32
		CALL	putch
		ADDI	sp, sp, 24
		SW	s2, -328(fp)
		LW	s2, -400(fp)
		SW	s3, -336(fp)
		LI	s3, 1
		ADDW	s4, s2, s3
		SW	s4, -400(fp)
		SW	s2, -360(fp)
		SW	s4, -368(fp)
		J	.L40
.L42:
		ADDI	sp, sp, -24
		LI	a0, 10
		CALL	putch
		ADDI	sp, sp, 24
		LI	t0, 0
		SW	t0, -408(fp)
		J	.L28

